using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.ComponentModel;

namespace App
{
    public class PanTop : System.Windows.Forms.Panel
    {
        private bool m_DrawTop = true;
        public PanTop()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        }


        [Description("Draw Top Line")]
        [System.ComponentModel.RefreshProperties(RefreshProperties.Repaint)]
        public bool DrawTop
        {
            get { return m_DrawTop; }
            set { m_DrawTop = value; }
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            if (ClientRectangle.Width == 0 || ClientRectangle.Height == 0)
                return;

            if (m_DrawTop)
            {
                SolidBrush br = new SolidBrush(Common.Blue);
                e.Graphics.FillRectangle(br, ClientRectangle);
                br.Dispose();
                //e.Graphics.DrawLine(new Pen(Color.FromArgb(141, 178, 227)),
                //        ClientRectangle.X,
                //        ClientRectangle.Y,
                //        ClientRectangle.X + ClientRectangle.Width,
                //        ClientRectangle.Y);
                Rectangle rectShadow = new Rectangle(ClientRectangle.X, ClientRectangle.Y - 1, ClientRectangle.Width, 4);

                //DrawHelper.DrawShadowTop(e.Graphics, rectShadow);
            }
            //DrawHelper.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(32, Color.Black)),
            //    rectShadow, 2f);
            //DrawHelper.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(22, Color.Black)),
            //    rectShadow, 2f);
            //DrawHelper.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(12, Color.Black)),
            //    rectShadow, 2f);
            //DrawHelper.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(8, Color.Black)),
            //    rectShadow, 2f);
            for (int i = 0; i < this.Controls.Count; i++)
            {
                if (this.Controls[i].Name.StartsWith("txtA"))
                {
                    DrawHelper.DrawShadow(e.Graphics, this.Controls[i].Bounds);
                }
            }
        }

        protected override void OnResize(EventArgs eventargs)
        {
            base.OnResize(eventargs);
            this.Invalidate();
        }
    }
}
